package ru.sviridov.sellandbuy;

import ru.sviridov.sellandbuy.tools.AdsTools;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

public class NewAdvertisingActivity extends Activity {
	private static final int REQUEST_CATEGORY = 1;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		ContentViewMapper.setContentView(this);
	}
	
	public void onClickCreate(View view){
		Toast.makeText(this, R.string.creating_new_ads, Toast.LENGTH_LONG).show();
		AdsTools.createNewAds(this, null); //TODO fill creation
	}
	
	public void onClickSelectCategory(View view){
		startActivityForResult(new Intent(this, ChooseCategoryActivity.class), REQUEST_CATEGORY);
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if(requestCode==REQUEST_CATEGORY && resultCode==RESULT_OK) {
			TextView tvCategory = (TextView) findViewById(R.id.tvCategory);
			tvCategory.setText(data.getStringExtra(ChooseCategoryActivity.CATEGORY_NAME));
		}			
			
		super.onActivityResult(requestCode, resultCode, data);
	}
}
